/*
 * Session.java
 *
 * Created on March 21, 2007, 5:43 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */


package finalintex2web;
import java.util.*;
import java.io.*;
import java.sql.*;

/**
 * database access object for ravenue sources
 */
public class Session {
    
    private EmployeeBO emp = null;
    private StoreBO store = null;
    private String date = null;
   
    
    
    ///////////////////////////////////////
    ///   Singleton pattern
     private static Session instance = null;
   
    
    /** Creates a new instance of RevenueSourceDAO */
    private Session() {
      this.setDate(); 
    }
   
    /**
     * 
     * @return 
     */
    public static synchronized Session getInstance() {
        if (instance == null) {
            instance = new Session();
        }
     
        return instance;
    }

    /**
     * 
     * @return 
     */
    public EmployeeBO getEmp() {
        return emp;
    }

    /**
     * 
     * @param id 
     * @throws intex2.DataException 
     */
    public void setEmp(String id) throws DataException {
        try{
        this.emp = EmployeeDAO.getInstance().read(id);
        }catch(Exception e){throw new DataException("employee no found",e);}
    }

    /**
     * 
     * @return 
     */
    public StoreBO getStore() {
        return store;
    }

    /**
     * 
     * @param id 
     * @throws intex2.DataException 
     */
    public void setStore(String id) throws DataException{
        try{
        this.store = StoreDAO.getInstance().read(id);
        }catch(Exception e){throw new DataException("store no found",e);}
    }

    /**
     * 
     * @return 
     */
    public String getDate() {
        return date;
    }

    private void setDate() {
        java.util.Date d = new java.util.Date();
        date = (d.getMonth()+1) + "/" + d.getDate() + "/" + 2007;
        System.out.println("today's date = "+ this.date);
    }
}